package com.iseastar.guojiang.logic;

import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.graphics.Bitmap;
import android.os.AsyncTask;
import android.text.TextUtils;
import android.widget.ImageView;

import com.iseastar.guojiang.BeeApplication;
import com.iseastar.guojiang.app.AppCache;
import com.iseastar.guojiang.consts.AppConfig;
import com.iseastar.guojiang.consts.MsgID;
import com.iseastar.guojiang.model.IDCardInfoBean;
import com.iseastar.guojiang.model.NewParcelBean;
import com.iseastar.guojiang.model.OrderBean;
import com.iseastar.guojiang.model.PacketBean;
import com.iseastar.guojiang.model.UserBean;
import com.shouhuobao.take.utils.StringUtils;

import org.json.JSONObject;

import java.io.File;
import java.io.Serializable;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

import droid.frame.App;
import droid.frame.Config;
import droid.frame.activity.HandlerMgr;
import droid.frame.utils.android.Log;
import droid.frame.utils.android.MathUtils;
import droid.frame.utils.http.BitmapUtils;
import droid.frame.utils.http.HttpClient;
import droid.frame.utils.http.HttpLoader;
import droid.frame.utils.http.HttpParam;
import droid.frame.utils.http.HttpReq;
import droid.frame.utils.rsa.DesUtil;

import static com.iseastar.guojiang.consts.AppConfig.getGuoErServerUrl;
import static com.iseastar.guojiang.consts.AppConfig.getTakeUrl;

/**
 * 客户端用到的网络请求 {@link AppConfig}
 *
 * @author coffee<br>
 * 2014年9月20日下午3:37:41
 */
public class AppHttp {
    private static AppHttp instance;
    // 已完成订单分页大小
    public final static int page_size_order_history = 10;
    // 未完成订单......
    public final static int page_size_order_wait = 5;

    private String versionCode = null;
    private final String PAGE_SIZE = "100";

    private AppHttp() {

    }

    public static AppHttp getInstance() {
        if (instance == null) {
            instance = new AppHttp();
        }
        return instance;
    }

    /**
     * 上传多张图片
     */
    public void postFils(String... imageUrl) {
        new AsyncTask<String, Void, String>() {
            @Override
            protected String doInBackground(String... params) {
                String result = "";
                result = HttpClient.postFiles(AppConfig.getFileUrl(), params);
                return result;
            }

            protected void onPostExecute(String result) {
                HandlerMgr.sendMessage(MsgID.upload_image, result);
            }
        }.execute(imageUrl);
    }

    /**
     * 火箭下上传多张图片，设置tag
     *
     * @param imageUrl
     */
    public void postFils(final int msgId, String... imageUrl) {
        new AsyncTask<String, Void, String>() {
            @Override
            protected String doInBackground(String... params) {
                String result = "";
                result = HttpClient.postFiles(AppConfig.getFileUrl(), params);
                return result;
            }

            protected void onPostExecute(String result) {
                HandlerMgr.sendMessage(msgId, result);
            }
        }.execute(imageUrl);
    }

    private String getVersion() {
        if (versionCode != null) {
            return versionCode;
        }
        Context context = App.getContext();
        PackageManager packageManager = context.getPackageManager();
        // getPackageName()是你当前类的包名，0代表是获取版本信息
        try {
            PackageInfo packInfo = packageManager.getPackageInfo(context.getPackageName(), 0);
            versionCode = packInfo.versionCode + "";
        } catch (NameNotFoundException e) {
            e.printStackTrace();
        }
        return versionCode;
    }

    public void crashUpload() {
        try {
            final String uploadUrl = "http://test.guoer-jam.shouhuobao.com:8011/guoer-jam/crash/uploadCrash";
            new Thread(new Runnable() {
                @Override
                public void run() {
                    // /storage/emulated/0/shouhuobao/crash
                    String crashDir = Config.getCrashDir();
                    if (crashDir == null) {
                        return;
                    }
                    File crashFile = new File(crashDir);
                    if (crashFile == null || crashFile.exists() == false) {
                        return;
                    }
                    ArrayList<File> files = new ArrayList<File>();
                    files.addAll(Arrays.asList(crashFile.listFiles()));
                    if (files.size() == 0) {
                        return;
                    }
                    Collections.sort(files);
                    File file = files.get(files.size() - 1);
                    // String content = FileUtils.read(file.getPath());
                    // MobclickAgent.reportError(instance, System.currentTimeMillis() + "");
                    String result = HttpClient.postFile(uploadUrl, file);
                    // 1.0.1_2015-06-18_15.txt
                    // result==/app/logs/crash/login.xml
                    if (result != null && result.trim().endsWith(file.getName())) {
                        file.delete();
                    }
                }
            }).start();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 用户登录
     *
     * @param username
     * @param password
     * @param isJam    是否裹将<br>
     *                 true 裹将, false 驿站
     */
    public void login(String username, String password, boolean isJam) {
        int type = isJam ? 1 : 0;
        Map<String, Object> map = createParamsMap();
        map.put("phone", username);
        map.put("password", password);
        map.put("device", 1);
        map.put("isJam", type);
        map.put(HttpParam.postText, true);
        map.put(HttpParam.toastNet, true);
        //
        HttpReq req = new HttpReq(map, MsgID.login_in + type);
        // req.setHttpRunnable(new ExpressRunnable(req.getUrl(), req.getParams()));
        req.setUrl(getTakeUrl() + "login");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 修改初始密码
     *
     * @param userId
     * @param password
     */
    public void loginPasswordChange(int userId, String password, boolean isJam) {
        int type = isJam ? 0 : 1;
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("id", userId);
        map.put("isJam", type);
        map.put("password", password);
        map.put("version", getVersion());
        map.put(HttpParam.postText, true);
        map.put(HttpParam.toastNet, true);
        //
        HttpReq req = new HttpReq(map, MsgID.login_password_change + type);
        req.setUrl(getTakeUrl() + "editPassword");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 获取快递员负责的智能柜列表
     *
     * @param userId
     */
    public void cabinetGetAlls(int userId) {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("courierId", userId);
        map.put("version", getVersion());
        map.put(HttpParam.postText, true);
        map.put(HttpParam.toastNet, true);
        HttpReq req = new HttpReq(map, MsgID.cabinetGetAlls);
        req.setUrl(getTakeUrl() + "station/queryStationByCourierId2/");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 查询指定智能柜Id的柜子订单
     *
     * @param cabinetId
     */
    public void cabinetGetById(int cabinetId, String code) {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("stationId", cabinetId);
        map.put("version", getVersion());
        map.put("checkCode", code);
        map.put(HttpParam.postText, true);
        map.put(HttpParam.toastNet, true);
        HttpReq req = new HttpReq(map, MsgID.cabinetGetById);
        req.setUrl(getTakeUrl() + "station/queryParcelsByStationId/");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 获取新订单，默认type为待处理订单
     *
     * @param userId
     */
    public void orderListNewGet(int userId) {
        orderListNewGet(userId, "1", MsgID.orderlist_get);
    }

    /**
     * 获取新订单_列表
     */
    private void orderListNewGet(int userId, String type, int messageId) {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("id", userId);
        map.put("version", getVersion());
        // 默认为1 显示待处理订单
        map.put("type", type);
        map.put(HttpParam.postText, true);
        map.put(HttpParam.toastNet, true);
        //
        HttpReq req = new HttpReq(map, messageId);
        req.setUrl(getTakeUrl() + "listOrder");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 获取订单详情接口
     *
     * @param orderId
     */
    public void orderShowNewGet(Serializable orderId) {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("id", orderId);
        map.put("version", getVersion());
        map.put(HttpParam.postText, true);
        map.put(HttpParam.toastNet, true);
        //
        HttpReq req = new HttpReq(map, MsgID.ordershow_get);
        req.setUrl(getTakeUrl() + "showOrder");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 取消订单
     *
     * @param userId
     * @param orderId
     * @param reason  1、电话打不通 2、用户不想寄了 3、回店铺
     * @param other   取消其他原因
     */
    public void orderCancel(int userId, Serializable orderId, int reason, String other) {
        Map<String, Object> map = getCancelMap(userId, orderId, reason, other);
        //
        HttpReq req = new HttpReq(map, MsgID.order_cancel);
        req.setUrl(getTakeUrl() + "cancelOrder");
        // req.setArg1(orderId);
        HttpLoader.getInstance().sendReq(req);
    }

    private Map<String, Object> getCancelMap(int userId, Serializable orderId, int reason, String other) {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("id", userId);
        if (orderId != null) {
            map.put("orderId", orderId);
        }
        map.put("reason", reason);
        map.put("version", getVersion());
        map.put("content", other);
        map.put(HttpParam.postText, true);
        map.put(HttpParam.toastNet, true);
        return map;
    }

    /**
     * 报价
     *
     * @param order 订单信息
     */
    public void orderQuotePrice(OrderBean order) {
        //
        String[] info = getOrderPrice(order);
        //
        int userId = getUserId();
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("id", userId);
        map.put("orderId", order.getOrderId());
        // map.put("payWay", type);
        map.put("parcels", info[0]);
        map.put("cost", info[1]);// price
        map.put("version", getVersion());
        map.put(HttpParam.postText, true);
        //
        HttpReq req = new HttpReq(map, MsgID.order_pay_price);
        req.setUrl(getTakeUrl() + "quotePrice");
        HttpLoader.getInstance().sendReq(req);
    }

    private String[] getOrderPrice(OrderBean order) {
        StringBuilder sb = new StringBuilder();
        sb.append("[");
        // {"cost":"30","number":"1234567890","weight":"2","weightType":"1"}
        String price = "0";
        for (Iterator<PacketBean> it = order.getPackets().iterator(); it.hasNext(); ) {
            PacketBean item = it.next();
            sb.append("{");
            sb.append("'cost':").append(item.getPrice()).append(",");
            sb.append("'number':'").append(item.getNumber()).append("',");
            sb.append("'weight':").append(item.getWeight()).append(",");
            sb.append("'weightType':").append(item.getWeightType()).append(",");
            sb.append("'bagCode':'").append(item.getBagCode()).append("',");
            sb.append("'expressCompanyId':'").append(item.getExpressCompanyId()).append("',");
            sb.append("'expressCompanyName':'").append(item.getExpressCompanyName()).append("'");
            sb.append("}");
            if (it.hasNext()) {
                sb.append(",");
            }
            price = MathUtils.add(item.getPrice(), price) + "";
        }
        sb.append("]");
        String parcels = sb.toString().replace("'", "\"");
        return new String[]{parcels, price};
    }

    /**
     * 支付成功的回调 -- 通知服务器修改状态
     *
     * @param orderId payType 微信为1
     */
    public void orderPayCallBack(String orderId, int payType) {
        Map<String, Object> map = createParamsMap();
        UserBean user = AppCache.getUser();
        map.put("userId", user.getId());
        map.put("orderId", orderId);
        map.put("payType", payType);
        map.put("openIdType", -2);

        HttpReq req = new HttpReq(map, MsgID.pay_return);
        req.setUrl(getTakeUrl() + "appPayReturn");
        // req.setUrl(getServerUrl() + "weiXinPayReturn");
        HttpLoader.getInstance().sendReq(req);
    }

    private int getUserId() {
        BeeApplication app = (BeeApplication) (BeeApplication.getContext());
        return AppCache.getUser().getId();
    }

    /**
     * 验证寄件码、核销码
     *
     * @param orderId
     * @param code    寄件码
     */
    public void orderCheckCode(Serializable orderId, String code) {
        Map<String, Object> map = createParamsMap();
        map.put("id", getUserId());
        map.put(HttpParam.toastNet, true);
        //
        HttpReq req = new HttpReq(map, MsgID.order_check);
        req.setUrl(getTakeUrl() + "upDoor/cancelAfterVerification/" + orderId + "/" + code);
        HttpLoader.getInstance().sendReq(req);
    }

    private HashMap<String, Object> createParamsMap() {
        UserBean bean = AppCache.getUser();
        HashMap<String, Object> map = new HashMap<String, Object>();
        map.put("version", getVersion());
        map.put("device", 1);
        if (bean.getToken() != null) {
            map.put("phone", bean.getToken().getPhone());
            map.put("token", URLEncoder.encode(bean.getToken().getToken()));
        }
        map.put(HttpParam.postText, true);
        map.put(HttpParam.toastNet, true);
        return map;
    }

    /**
     * 估价、获取价格
     *
     * @param id     包裹id
     * @param exId   快递公司id
     * @param weight 重量
     */
    public void getParcelPrice(String id, String exId, String weight) {
        Map<String, Object> map = createParamsMap();
        map.put("id", id);
        map.put("exId", exId);
        map.put("weight", weight);
        map.put("version", getVersion());
        HttpReq req = new HttpReq(map, MsgID.get_Parcel_Price);
        req.setUrl(getTakeUrl() + "getParcelPrice");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 裹将忘记密码使用
     *
     * @param phone
     */
    public void loginSMSVerifyNum(String phone) {
        Map<String, Object> map = createParamsMap();
        map.put("phone", phone);
        HttpReq req = new HttpReq(map, MsgID.send_verifyNum);
        req.setUrl(getTakeUrl() + "sendVerifyNum");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 获取短信验证码
     *
     * @param phone
     * @param type  1裹儿 2店老板 3快递员
     */
    public void loginSMSVerifyCode(String phone, int type, String codeType) {
        Map<String, Object> map = createParamsMap();
        map.put("phone", phone);
        map.put("type", type);
        if (!StringUtils.isEmpty(codeType)) {
            map.put("smsType", codeType);
        }
        map.put("timestamp", System.currentTimeMillis());
        JSONObject jsonObject = new JSONObject(map);
        String data = DesUtil.ebotongEncrypto(jsonObject.toString());
        map.put("sendInfo", data);
        HttpReq req = new HttpReq(map, MsgID.send_verifyNum);
        req.setUrl(getTakeUrl() + "sendVerifyCodeDes");
//        req.setUrl(getTakeUrl() + "sendVerifyCode");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 找回密码，重置密码
     *
     * @param phone
     * @param code
     * @param password1
     * @param password2
     */
    public void confirmVerifyNum(String phone, String code, String password1, String password2) {
        Map<String, Object> map = createParamsMap();
        map.put("phone", phone);
        map.put("code", code);
        map.put("password1", password1);
        map.put("password2", password2);

        HttpReq req = new HttpReq(map, MsgID.confirmVerifyNum);
        req.setUrl(getTakeUrl() + "editPassword");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 登录、确认验证码
     *
     * @param phone
     */
    public void confirmLoginVerifyCode(String phone, String code) {
        Map<String, Object> map = createParamsMap();
        map.put("phone", phone);
        map.put("verifyCode", code);
        HttpReq req = new HttpReq(map, MsgID.confirmVerifyNum);
        req.setUrl(getTakeUrl() + "login/confirmVerifyCode");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * @param url       传入绝对路径
     * @param imageView
     */
    public void loadImage(final String url, final ImageView imageView) {
        // 默认检查本地缓存
        loadImage(url, imageView, true);
    }

    /**
     * @param url          传入绝对路径
     * @param isCheckLocal 是否检查本地缓存
     * @param imageView
     */
    public void loadImage(final String url, final ImageView imageView, final boolean isCheckLocal) {
        if (imageView == null) {
            Log.w("app:logic", "imageview为空, url不予请求", null);
            return;
        }
        // 头像
        new AsyncTask<Void, Void, Bitmap>() {
            @Override
            protected Bitmap doInBackground(Void... params) {
                // 头像
                Bitmap image = BitmapUtils.loadBitmapFromNet(url, isCheckLocal);
                return image;
            }

            @Override
            protected void onPostExecute(Bitmap result) {
                if (result != null && imageView != null) {
                    imageView.setImageBitmap(result);
                }
            }
        }.execute();
    }

    /**
     * @param url          传入绝对路径
     * @param isCheckLocal 是否检查本地缓存
     * @param imageView
     */
    public void loadImageAutoRotate(final String url, final ImageView imageView, final boolean isCheckLocal) {
        if (imageView == null) {
            Log.w("app:logic", "imageview为空, url不予请求", null);
            return;
        }
        // 头像
        new AsyncTask<Void, Void, Bitmap>() {
            @Override
            protected Bitmap doInBackground(Void... params) {
                // 头像
                Bitmap image = BitmapUtils.loadBitmapFromNet(url, isCheckLocal);
                return image;
            }

            @Override
            protected void onPostExecute(Bitmap result) {
                if (result != null && imageView != null) {
                    Bitmap newResult = BitmapUtils.toRotation(result, 90);
                    imageView.setImageBitmap(newResult);
                }
            }
        }.execute();
    }

    /**
     * 柜子、拒收
     *
     * @param itemId 订单id
     * @param reason
     */
    public void orderReject(Serializable itemId, String reason) {
        Map<String, Object> map = createParamsMap();
        map.put("orderId", itemId);
        map.put("reason", reason);
        map.put(HttpParam.postText, true);

        HttpReq req = new HttpReq(map, MsgID.order_refuse);
        req.setUrl(getTakeUrl() + "box/reserve");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 驿站、拒收
     *
     * @param itemId 包裹id
     * @param reason
     */
    public void orderReject2(Serializable itemId, String reason, String stationMobile) {
        Map<String, Object> map = createParamsMap();
        map.put("parcelId", itemId);
        map.put("reason", reason);
        map.put("stationMobile", stationMobile);
        int userId = AppCache.getUser().getId();
        map.put("courierId", userId);
        map.put(HttpParam.postText, true);

        HttpReq req = new HttpReq(map, MsgID.order_refuse);
        req.setUrl(getTakeUrl() + "station/refuseParcel");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 异常申报
     *
     * @param
     */
    public void orderException(Serializable parcelId, Serializable stationId, String stationMobile, String bagCode, String reason) {
        Map<String, Object> map = createParamsMap();
        map.put("parcelId", parcelId);
        map.put("reason", reason);
        map.put("postStationId", stationId);
        map.put("stationMobile", stationMobile);
        map.put("bagCode", bagCode);
        //
        int userId = AppCache.getUser().getId();
        map.put("courierId", userId);
        map.put(HttpParam.postText, true);
        //
        HttpReq req = new HttpReq(map, MsgID.order_exception);
        req.setUrl(getTakeUrl() + "station/abnormalParcel");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 校验二维码是否合法
     *
     * @param type 1有袋上门,0代表到柜,2揽收
     */
    public void cabinetEvaluateBagCode(String bagcode, Serializable orderId, int type) {
        Map<String, Object> map = createParamsMap();
        map.put(HttpParam.postText, true);
        //
        UserBean user = AppCache.getUser();
        int userId = user.getId();
        HttpReq req = new HttpReq(map, MsgID.cabinet_evaluate_bagcode);
        req.setUrl(getTakeUrl() + "box/scanBarCode/" + bagcode + "/" + orderId + "/" + userId + "/" + type);
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 柜子揽收
     */
    public void collectBoxParcel(String bagcode, String parcelId) {
        Map<String, Object> map = createParamsMap();
        map.put(HttpParam.postText, true);
        //
        UserBean user = AppCache.getUser();
        int userId = user.getId();
        map.put("courierId", userId);
        map.put("parcelId", parcelId);
        map.put("bagCode", bagcode);
        HttpReq req = new HttpReq(map, MsgID.cabinet_evaluate_bagcode);
        req.setUrl(getTakeUrl() + "station/collectParcel");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 店小三 发送版本检测的请求
     */
    public void takeAppUpgrade(Integer showMessage) {
        Map<String, Object> map = createParamsMap();
        map.put("type", 4);
        HttpReq req = new HttpReq(map, MsgID.station_update);
        req.setUrl(getTakeUrl() + "release/check");
        if (showMessage != null) {
            req.setArg1(showMessage);
        }
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 店小三、通过寄件码收取用户包裹
     *
     * @param ids 传入integer （单个包裹的id） 或者String逗号分隔
     */
    public void stationReceiveByIds(Object ids) {
        UserBean user = AppCache.getUser();
        Map<String, Object> map = createParamsMap();
        map.put("stationId", user.getStationId());
        map.put("ids", ids);
        //
        HttpReq req = new HttpReq(map, MsgID.parcel_recv_by_ids);
        req.setUrl(getTakeUrl() + "updateParcelTake");
        if (ids instanceof Integer) {
            req.setArg1(Integer.valueOf(ids + ""));
        }
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 店小三 交接记录
     *
     * @param pageNum 0第一页
     */
    public void stationTradeRecord(int stationId, int pageNum) {
        Map<String, Object> map = createParamsMap();
        map.put("stationId", stationId);
        map.put(HttpParam.postText, true);// get请求
        map.put("pageNum", pageNum);// 页数
        map.put("pageSize", PAGE_SIZE);// 分页
        HttpReq req = new HttpReq(map, MsgID.trade_record);
        req.setUrl(getTakeUrl() + "join/record");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 店小三 已交接的包裹
     */
    public void stationTradeRecordFinish(int stationId, int courierId, long joinTime) {
        Map<String, Object> map = createParamsMap();
        map.put("stationId", stationId);
        map.put(HttpParam.postText, true);// get请求
        map.put("courierId", courierId);// 裹将id
        map.put("joinTime", joinTime);// 交接时间
        HttpReq req = new HttpReq(map, MsgID.trade_record_finish);
        req.setUrl(getTakeUrl() + "join/already");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 店小三 异常包裹
     */
    public void stationParcelAbnormalAlls(int stationId) {
        Map<String, Object> map = createParamsMap();
        map.put("stationId", stationId);
        map.put(HttpParam.postText, true);// get请求
        HttpReq req = new HttpReq(map, MsgID.parcel_abnormal_alls);
        req.setUrl(getTakeUrl() + "findAbnormalParcel");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 店小三 查询从店主待取走的包裹订单
     */
    public void stationParcelWaitAlls(int stationId) {
        Map<String, Object> map = createParamsMap();
        map.put("stationId", stationId);
        map.put(HttpParam.postText, true);// get请求
        HttpReq req = new HttpReq(map, MsgID.wait_take_alls);
        req.setUrl(getTakeUrl() + "station/queryUnTakeParcels");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 店小三 查询从店主待取走的包裹订单
     */
    public void stationParcelOrderedAlls(int stationId) {
        Map<String, Object> map = createParamsMap();
        map.put("stationId", stationId);
        map.put(HttpParam.postText, true);// get请求
        HttpReq req = new HttpReq(map, MsgID.ordered_take_alls);
        req.setUrl(getTakeUrl() + "station/queryUnPostParcels");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 店小三 待取走的包裹数量
     */
    public void stationParcelWaitNum(int stationId) {
        Map<String, Object> map = createParamsMap();
        map.put("stationId", stationId);
        map.put(HttpParam.postText, true);// get请求
        HttpReq req = new HttpReq(map, MsgID.wait_take_num);
        req.setUrl(getTakeUrl() + "index");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 店小三 (寄件码)核对包裹信息
     */
    public void stationParcelByCode(String checkCode) {
        Map<String, Object> map = createParamsMap();
        map.put("checkCode", checkCode);
        map.put(HttpParam.postText, true);// get请求
        //
        HttpReq req = new HttpReq(map, MsgID.parcel_by_6code);
        req.setUrl(getTakeUrl() + "parcelListByCode");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 店小三 （扫码）核对包裹信息
     */
    public void stationParcelCheckAlls(String bagCode) {
        Map<String, Object> map = createParamsMap();
        UserBean user = AppCache.getUser();
        map.put("stationId", user.getId());
        map.put("bagCode", bagCode);
        map.put(HttpParam.postText, true);// get请求
        HttpReq req = new HttpReq(map, MsgID.parcel_by_bagCode);
        req.setUrl(getTakeUrl() + "checkParcelList");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 裹将、查询指定驿站的id
     *
     * @param code 驿站的二维码
     */
    public void stationGetId(String code) {
        Map<String, Object> map = createParamsMap();
        map.put("qrUrlCode", code);
        HttpReq req = new HttpReq(map, MsgID.station_getId_by_scancode);
        req.setUrl(getTakeUrl() + "station/findStationIdByQrUrlCode");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 裹将、扫码查询指定驿站下的所有包裹
     *
     * @param stationId 驿站的二维码
     */
    public void stationGetAlls(Serializable stationId) {
        Map<String, Object> map = createParamsMap();
        map.put("stationId", stationId);
        HttpReq req = new HttpReq(map, MsgID.station_getList_by_id);
        req.setUrl(getTakeUrl() + "station/queryUnTakeParcels");
        // req.setUrl(AppConfig.getServerUrl() + "station/waitCollectParcels");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 裹将、核对包裹、揽收
     */
    public void stationParclCheck(String phone, String ids) {
        ids = ids.replace("[", "").replace("]", "").replace(" ", "");
        Map<String, Object> map = createParamsMap();
        UserBean user = AppCache.getUser();
        map.put("courierId", user.getId());
        map.put("stationMobile", phone);
        map.put("parcelIds", ids);
        //
        HttpReq req = new HttpReq(map, MsgID.station_parcel_check);
        req.setUrl(getTakeUrl() + "station/collectParcels");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 通知店老板 裹将来了
     *
     * @param phone 店老板手机
     */
    public void stationCourierArrive(String phone) {
        Map<String, Object> map = createParamsMap();
        UserBean user = AppCache.getUser();
        map.put("courierId", user.getId());
        map.put("stationMobile", phone);
        //
        HttpReq req = new HttpReq(map, MsgID.station_courier_arrive);
        req.setUrl(getTakeUrl() + "station/courierArrive");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * take首页
     */
    public void takeIndex() {
        Map<String, Object> map = createParamsMap();
        UserBean user = AppCache.getUser();
        if (null == user.getStationId()) {
            return;
        }
        map.put("userId", user.getId());
        map.put("stationId", user.getStationId());
        HttpReq req = new HttpReq(map, MsgID.take_index);
        req.setUrl(getTakeUrl() + "index/queryCount");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 启动的时候调用, 获取APP的banner信息
     * int toudi_app = 1;// 火箭投递IOS
     * int lianmeng_app = 2;// 火箭投递安卓
     * int toudi_ios = 4;//火箭联盟IOS
     * int lianmeng_ios = 8; // 火箭联盟安卓
     * int xiaochengxu = 16; // 小程序
     */
    public void getBannerData(String city) {
        Map<String, Object> map = createParamsMap();
        map.put("city", city);
        map.put("appType", 8);
        HttpReq req = new HttpReq(map, MsgID.take_get_banner_data);
        req.setUrl(getTakeUrl() + "banner/queryBanner");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 代收包裹录入
     *
     * @param number
     * @param companyName
     * @param receiverPhone
     * @param receiverName
     * @param remark
     */
    public void takeParcelInput(String number, String companyName, //
                                String receiverPhone, String receiverName, String remark, boolean isBig) {
        Map<String, Object> map = createParamsMap();
        UserBean user = AppCache.getUser();
        map.put("userId", user.getId());
        map.put("stationId", user.getStationId());
        map.put("expressNumber", number);
        map.put("expressCompanyName", companyName);
        map.put("receiverPhone", receiverPhone);
        map.put("receiverName", receiverName);
        map.put("remark", remark);
        map.put("isBig", isBig ? 1 : 0);

        HttpReq req = new HttpReq(map, MsgID.take_parcel_input);
        req.setUrl(getTakeUrl() + "takeParcel/submit2");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 查询包裹列表
     *
     * @param parcelType 1已到店 2已取走 3已超期
     * @param page       从1开始
     */
    public void takeParcelQueryList(int parcelType, int page, String expressCompany, String date) {
        Map<String, Object> map = createParamsMap();
        UserBean user = AppCache.getUser();
        // map.put("stationId", user.getId());
        map.put("stationId", user.getStationId());
        map.put("type", parcelType);
        map.put("pageNum", page);
        map.put("expressCompany", expressCompany);
        map.put("date", date);

        HttpReq req = null;
        if (parcelType == 1) {
            req = new HttpReq(map, MsgID.take_parcel_reachstore);
        } else if (parcelType == 2) {
            req = new HttpReq(map, MsgID.take_parcel_takes);
        } else {
            req = new HttpReq(map, MsgID.take_parcel_pasted);
        }
        req.setUrl(getTakeUrl() + "takeParcel/queryByStatus");
        HttpLoader.getInstance().sendReq(req);
    }

    //    /**
    //     * 查询快递公司列表
    //     */
    //    public void takeQueryPostCompanyList() {
    //        Map<String, Object> map = createParamsMap();
    //        HttpReq req = new HttpReq(map, MsgID.take_query_postcompanylist);
    //        req.setUrl(getTakeUrl() + "expressCompany/queryAll");
    //        HttpLoader.getInstance().sendReq(req);
    //    }

    /**
     * 包裹查询
     *
     * @param keywords
     * @param type     1 正常 2下拉刷新
     */
    public void takeParcelSearch(int type, String keywords) {
        Map<String, Object> map = createParamsMap();
        UserBean user = AppCache.getUser();
        // map.put("stationId", user.getId());
        map.put("stationId", user.getStationId());
        map.put("keywords", keywords);
        HttpReq req = null;
        if (type == 1) {
            req = new HttpReq(map, MsgID.take_parcel_search);
        } else {
            req = new HttpReq(map, MsgID.take_parcel_search + 1);
        }
        req.setUrl(getTakeUrl() + "takeParcel/search");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 验证包裹
     *
     * @param parcelId
     */
    public void takeParcelByCode(String parcelId, String checkCode) {
        Map<String, Object> map = createParamsMap();
        UserBean user = AppCache.getUser();
        // map.put("stationId", user.getId());
        map.put("stationId", user.getStationId());
        map.put("checkCode", checkCode);// null正常取走, 1、详情页面("确认已取走")
        map.put("parcelId", parcelId);
        HttpReq req = new HttpReq(map, MsgID.take_parcel_check_bycheckcode);
        req.setUrl(getTakeUrl() + "takeParcel/takeAwayByCode");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 取走指定的包裹
     *
     * @param parcelIds
     */
    public void takeParcelAway(String parcelIds, Integer type) {
        Map<String, Object> map = createParamsMap();
        UserBean user = AppCache.getUser();
        // map.put("stationId", user.getId());
        map.put("stationId", user.getStationId());
        map.put("type", type);// null正常取走, 1、详情页面("确认已取走")
        map.put("parcelIds", parcelIds);
        HttpReq req = new HttpReq(map, MsgID.take_parcel_away);
        req.setUrl(getTakeUrl() + "takeParcel/takeAwayByIds");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 取走包裹
     *
     * @param checkCode
     */
    public void takeParcelQueryByCode(String checkCode) {
        Map<String, Object> map = createParamsMap();
        UserBean user = AppCache.getUser();
        map.put("stationId", user.getStationId());
        map.put("checkCode", checkCode);
        HttpReq req = new HttpReq(map, MsgID.take_parcel_query_byCheckCode);
        req.setUrl(getTakeUrl() + "takeParcel/queryParcelByCode");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 获取短信数量
     */
    public void takeSmsCount() {
        Map<String, Object> map = createParamsMap();
        UserBean user = AppCache.getUser();
        map.put("userId", user.getId());
        // map.put("stationId", "1");
        HttpReq req = new HttpReq(map, MsgID.take_sms_query_count);
        req.setUrl(getTakeUrl() + "smsOrder/querySmsCount");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 短信--充值下单
     */
    public void takeSmsOrderSubmit(String smsCount) {
        Map<String, Object> map = createParamsMap();
        UserBean user = AppCache.getUser();
        map.put("userId", user.getId());
        map.put("stationId", user.getStationId());
        map.put("smsCount", smsCount);
        // map.put("stationId", "1");
        HttpReq req = new HttpReq(map, MsgID.take_sms_order_submit);
        req.setUrl(getTakeUrl() + "smsOrder/submit");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 短信 --充值支付
     */
    public void takeSmsOrderPay(String orderId, Integer payType) {
        Map<String, Object> map = createParamsMap();
        UserBean user = AppCache.getUser();
        map.put("userId", user.getId());
        map.put("orderId", orderId);
        // map.put("stationId", "1");
        HttpReq req = new HttpReq(map, MsgID.take_sms_order_pay);
        if (payType == 0) {
            req.setUrl(getTakeUrl() + "paySms/wxPay");
        } else {
            req.setUrl(getTakeUrl() + "paySms/aliPay");
        }
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * sms支付app端回调
     *
     * @param orderId
     * @param type
     */
    public void takePayReturn(String orderId, int type) {
        Map<String, Object> map = createParamsMap();
        map.put("orderId", orderId);
        map.put("payType", type);
        HttpReq req = new HttpReq(map, MsgID.take_smspay_return);
        req.setUrl(getTakeUrl() + "paySms/appPayReturn");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 查询parcel详情
     *
     * @param parcelId
     */
    public void takeParcelDetails(String parcelId) {
        Map<String, Object> map = createParamsMap();
        map.put("parcelId", parcelId);
        // map.put("stationId", "1");
        HttpReq req = new HttpReq(map, MsgID.take_parcel_details);
        req.setUrl(getTakeUrl() + "takeParcel/queryDetails");
        HttpLoader.getInstance().sendReq(req);
    }

    public void takeSmsNotice(String parcelId) {
        Map<String, Object> map = createParamsMap();
        map.put("parcelId", parcelId);
        // map.put("stationId", "1");
        HttpReq req = new HttpReq(map, MsgID.take_sms_notice);
        req.setUrl(getTakeUrl() + "takeParcel/smsNotice");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 查询包裹数量
     */
    public void takeQueryCount() {
        Map<String, Object> map = createParamsMap();
        UserBean user = AppCache.getUser();
        if (null == user.getStationId()) {
            return;
        }
        map.put("userId", user.getId());
        map.put("stationId", user.getStationId());
        HttpReq req = new HttpReq(map, MsgID.take_query_count);
        req.setUrl(getTakeUrl() + "index/queryCount2");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 完善驿站信息
     *
     * @param name
     * @param time
     * @param area
     * @param weixin
     * @param pics
     */
    public void regVerify(String name, String time, String area, String weixin, String pics) {
        Map<String, Object> map = createParamsMap();
        UserBean user = AppCache.getUser();
        map.put("userId", user.getId());
        map.put("community", name);
        map.put("serviceTime", time);
        map.put("area", area);
        map.put("weixin", weixin);
        map.put("stationPics", pics);

        HttpReq req = new HttpReq(map, MsgID.reg_verify_submit);
        req.setUrl(getTakeUrl() + "stationOpen/submitImprove");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 异常申报
     *
     * @param content
     */
    public void takeParcelException(String parcelId, String content) {
        Map<String, Object> map = createParamsMap();
        UserBean user = AppCache.getUser();
        map.put("userId", user.getId());
        map.put("stationId", user.getStationId());
        map.put("parcelId", parcelId);
        map.put("content", content);
        //
        HttpReq req = new HttpReq(map, MsgID.parcel_exception_submit);
        req.setUrl(getTakeUrl() + "takeParcel/exceptionSubmit");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 获取联系人信息
     */
    public void getReceiverInfo() {
        Map<String, Object> map = createParamsMap();
        UserBean user = AppCache.getUser();
        map.put("stationId", user.getStationId());
        HttpReq req = new HttpReq(map, MsgID.parcel_receive_info);
        req.setUrl(getTakeUrl() + "receiver/queryByStationId");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 通过手机号获取用户信息
     */
    public void getUserInfo() {
        Map<String, Object> map = createParamsMap();
        UserBean user = AppCache.getUser();
        map.put("phone", user.getPhone());
        HttpReq req = new HttpReq(map, MsgID.take_getuser_info);
        req.setUrl(getTakeUrl() + "stationOpen/queryOpenStatus");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 获取我的邮票列表
     */
    public void newCouponList(String cost) {
        Map<String, Object> map = createParamsMap();
        UserBean userBean = AppCache.getUser();
        map.put("userId", userBean.getId());
        map.put("stationId", userBean.getStationId());
        map.put("cost", cost);
        map.put("pageStart", 0);
        map.put("pageSize", 1000);// this.PAGE_SIZE
        String uri = "stamp/queryStampUsable";// 查询所有的
        if (cost != null) {
            uri = "selectCoupon"; // 根据订单价格查询可用的
        }
        map.put("cost", cost);
        HttpReq req = new HttpReq(map, MsgID.couponList);
        req.setUrl(getGuoErServerUrl() + uri);// 根据订单价格查询可用的
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 获取我的失效邮票列表
     */
    public void queryCouponDisableList(int msgID) {
        Map<String, Object> map = createParamsMap();
        UserBean userBean = AppCache.getUser();
        map.put("userId", userBean.getId());
        map.put("stationId", userBean.getStationId());
        map.put("pageSize", 1000);// this.PAGE_SIZE
        String uri = "stamp/queryStampDisable";// 查询所有的
        HttpReq req = new HttpReq(map, msgID);
        req.setUrl(getGuoErServerUrl() + uri);// 根据订单价格查询可用的
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 支付下单
     *
     * @param cost     需要支付的价钱
     * @param orderIds
     */
    public void orderSubmit(String cost, String orderIds) {
        Map<String, Object> map = createParamsMap();
        int userId = AppCache.getUser().getId();
        map.put("userId", userId);
        map.put("cost", cost);
        map.put("orderIds", orderIds);

        HttpReq req = new HttpReq(map, MsgID.order_submit);
        req.setUrl(getTakeUrl() + "order/submit");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 跳转到收银台
     */
    public void parcelOrderShow(String orderId, int parcelCount) {
        Map<String, Object> map = createParamsMap();
        int userId = AppCache.getUser().getId();
        map.put("userId", userId);
        map.put("orderId", orderId);
        map.put("parcelCount", parcelCount);
        HttpReq req = new HttpReq(map, MsgID.toPay_Show);
        String uri = "order/show";// 查询所有的
        req.setUrl(getTakeUrl() + uri);// 根据订单价格查询可用的
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 微信支付
     *
     * @param orderId
     * @param cost
     */
    public void weiXinPay(String orderId, String cost, String couponsId) {
        int userId = AppCache.getUser().getId();
        Map<String, Object> map = createParamsMap();
        map.put("orderId", orderId);
        map.put("userId", userId);
        map.put("cost", cost);
        map.put("realCost", cost);
        map.put("openIdType", -2);
        if (!TextUtils.isEmpty(couponsId)) {
            map.put("couponsId", couponsId);
        }
        HttpReq req = new HttpReq(map, MsgID.weixin_pay);
        req.setUrl(getTakeUrl() + "payParcel/wxPay");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 支付宝支付
     *
     * @param orderId
     * @param realCost
     */
    public void aliPay(String orderId, String realCost, String couponsId) {
        int userId = AppCache.getUser().getId();
        Map<String, Object> map = createParamsMap();
        map.put("orderId", orderId);
        map.put("userId", userId);
        map.put("cost", realCost);
        map.put("realCost", realCost);
        if (!TextUtils.isEmpty(couponsId)) {
            map.put("couponsId", couponsId);
        }
        HttpReq req = new HttpReq(map, MsgID.ali_pay);
        req.setUrl(getTakeUrl() + "payParcel/aliPay");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 支付成功的回调 -- 通知服务器修改状态
     *
     * @param orderId payType 微信为1  支付宝 2
     * @param isCover 1为补差价
     */
    public void orderPayCallBack(String orderId, int payType, int isCover) {
        Map<String, Object> map = createParamsMap();
        int userId = AppCache.getUser().getId();
        map.put("userId", userId);
        map.put("orderId", orderId);
        map.put("payType", payType);
        map.put("openIdType", -2);

        HttpReq req = new HttpReq(map, MsgID.wxPayCallback);
        if (isCover == 1) {
            req.setUrl(getTakeUrl() + "payParce2/appPayReturn");
        } else {
            req.setUrl(getTakeUrl() + "payParcel/appPayReturn");
        }
        // req.setUrl(getServerUrl() + "weiXinPayReturn");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 使用邮票支付
     *
     * @param orderId
     */
    public void useStampPay(String orderId, String couponsId) {
        int userId = AppCache.getUser().getId();
        Map<String, Object> map = createParamsMap();
        map.put("orderId", orderId);
        map.put("userId", userId);
        if (!TextUtils.isEmpty(couponsId)) {
            map.put("couponsId", couponsId);
        }
        HttpReq req = new HttpReq(map, MsgID.use_stampPay);
        req.setUrl(getTakeUrl() + "payParcel/stampPay");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 获取邮票商城购买记录列表
     */
    public void stampBuyHistoty() {
        Map<String, Object> map = createParamsMap();
        int stationId = AppCache.getUser().getStationId();
        map.put("stationId", stationId);
        map.put("userId", AppCache.getUser().getId());
        //
        HttpReq req = new HttpReq(map, MsgID.stamp_history);
        req.setUrl(getGuoErServerUrl() + "stamp/queryStampBuyHistory");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 购买邮票支付成功的回调 -- 通知服务器修改状态
     *
     * @param orderId payType 微信为1
     */
    public void stampPayCallBack(int orderId, int payType, int isCover) {
        Map<String, Object> map = createParamsMap();
        int userId = AppCache.getUser().getId();
        map.put("userId", userId);
        map.put("orderId", orderId);
        map.put("payType", payType);
        map.put("openIdType", -2);

        HttpReq req = new HttpReq(map, MsgID.wxPayCallback);
        if (isCover == 1) {
            req.setUrl(getTakeUrl() + "payStamp2/appPayReturn");
        } else {
            req.setUrl(getTakeUrl() + "payStamp/appPayReturn");
        }
        // req.setUrl(getServerUrl() + "weiXinPayReturn");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 支付宝
     *
     * @param orderId
     * @param realCost  实际支付金额
     * @param cost
     * @param couponsId
     */
    public void stampAliPay(int orderId, String realCost, String cost, int couponsId) {
        int userId = AppCache.getUser().getId();
        Map<String, Object> map = createParamsMap();
        map.put("orderId", orderId);
        map.put("userId", userId);
        map.put("cost", cost);
        map.put("realCost", realCost);
        if (couponsId != 0) {
            map.put("couponsId", couponsId);// 邮票
        }
        HttpReq req = new HttpReq(map, MsgID.stamp_alipay);
        req.setUrl(getTakeUrl() + "payStamp/aliPay");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * @param orderId
     * @param realCost  实际支付价格
     * @param cost      订单价格
     * @param couponsId
     */
    public void stampWeiXinPay(int orderId, String realCost, String cost, int couponsId) {
        int userId = AppCache.getUser().getId();
        Map<String, Object> map = createParamsMap();
        map.put("orderId", orderId);
        map.put("userId", userId);
        map.put("cost", cost);
        map.put("realCost", realCost);
        map.put("openIdType", -2);
        if (couponsId != 0) {
            map.put("couponsId", couponsId);// 邮票
        }
        //
        HttpReq req = new HttpReq(map, MsgID.stamp_wxpay);
        req.setUrl(getTakeUrl() + "payStamp/wxPay");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 获取邮票商城列表
     */
    public void stampStoreList() {//getServerUrl()
        Map<String, Object> map = createParamsMap();
        UserBean userBean = AppCache.getUser();
        map.put("phone", userBean.getPhone());
        map.put("stationId", userBean.getStationId());
        //
        HttpReq req = new HttpReq(map, MsgID.coupon_store);
        req.setUrl(getGuoErServerUrl() + "stamp/queryStampShop");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 邮票下单
     *
     * @param stampSids 邮票id
     */
    public void stampOrder(String stampSids) {
        HashMap<String, Object> map = createParamsMap();
        UserBean user = AppCache.getUser();
        map.put("userId", user.getId());
        map.put("stampSid", stampSids);
        HttpReq req = new HttpReq(map, MsgID.stamp_order);
        req.setUrl(getGuoErServerUrl() + "orderStamp/submit");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 进行袋子和包裹绑定
     *
     * @param bagCode  袋子编号
     * @param parcelId 包裹ID
     */
    public void bagCodeBindParcel(String bagCode, String parcelId) {
        Map<String, Object> map = createParamsMap();
        map.put("bagCode", bagCode);
        map.put("parcelId", parcelId);
        HttpReq req = new HttpReq(map, MsgID.bagcode_bindparcel);
        req.setUrl(getTakeUrl() + "station/bindBag");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 获取打印面单数据
     */
    public void getPrintOrderData() {
        Map<String, Object> map = createParamsMap();
        UserBean user = AppCache.getUser();
        map.put("courierId", user.getId());//
        HttpReq req = new HttpReq(map, MsgID.query_printorder_data);
        req.setUrl(getTakeUrl() + "ebill/queryParcels");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 根据条形码查询对应的包裹信息
     */
    public void queryParcelByBagCode(String bagCode) {
        Map<String, Object> map = createParamsMap();
        map.put("bagCode", bagCode);
        HttpReq req = new HttpReq(map, MsgID.queryparcel_by_bagcode);
        req.setUrl(getTakeUrl() + "ebill/queryEbill");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 打印成功后进行回调
     *
     * @param parcelId
     */
    public void queryPrintResult(String parcelId) {
        Map<String, Object> map = createParamsMap();
        map.put("parcelId", parcelId);
        HttpReq req = new HttpReq(map, MsgID.parcel_print_result);
        req.setUrl(getTakeUrl() + "ebill/updatePrintedState");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 查询我的业绩数据
     *
     * @param pageNum
     */
    public void queryMyPerformanceData(int pageNum) {
        Map<String, Object> map = createParamsMap();
        UserBean user = AppCache.getUser();
        map.put("courierId", user.getId());//
        map.put("pageNum", pageNum);
        HttpReq req = new HttpReq(map, MsgID.query_my_performance);
        req.setUrl(getTakeUrl() + "user/queryAchievement");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 业绩详情数据
     *
     * @param pageNum
     * @param date
     */
    public void queryPerformanceDetailData(int pageNum, String date) {
        Map<String, Object> map = createParamsMap();
        UserBean user = AppCache.getUser();
        map.put("courierId", user.getId());//
        map.put("pageNum", pageNum);
        map.put("date", date);
        HttpReq req = new HttpReq(map, MsgID.query_performance_detail);
        req.setUrl(getTakeUrl() + "user/queryAchievementDetail");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 代收 我的资金记录
     *
     * @param type    资金记录类型
     * @param pageNum 分页的页数
     */
    public void queryMyCapitalHistoryData(String type, int pageNum) {
        Map<String, Object> map = createParamsMap();
        UserBean user = AppCache.getUser();
        map.put("userId", user.getId());//
        map.put("pageNum", pageNum);
        map.put("type", type);
        HttpReq req = new HttpReq(map, MsgID.query_capital_history);
        req.setUrl(getTakeUrl() + "bankAccount/queryAccountLog");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 代收  查询是否绑定微信
     */
    public void queryIsBindWX() {
        Map<String, Object> map = createParamsMap();
        UserBean user = AppCache.getUser();
        map.put("userId", user.getId());//
        HttpReq req = new HttpReq(map, MsgID.query_isbind_wx);
        req.setUrl(getTakeUrl() + "user/queryWXAccount");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 代收  绑定微信账号
     */
    public void bindWXAccout(String openId, String wxAccountName, String wxHeadImgUrl) {
        Map<String, Object> map = createParamsMap();
        UserBean user = AppCache.getUser();
        map.put("userId", user.getId());//
        map.put("openId", openId);
        map.put("wxAccountName", wxAccountName);
        map.put("wxHeadImgUrl", wxHeadImgUrl);
        HttpReq req = new HttpReq(map, MsgID.bind_wx_accout);
        req.setUrl(getTakeUrl() + "user/bindOpenId");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 代收  解除微信绑定
     */
    public void deleteWXAccout() {
        Map<String, Object> map = createParamsMap();
        UserBean user = AppCache.getUser();
        map.put("userId", user.getId());//
        HttpReq req = new HttpReq(map, MsgID.delete_wx_accout);
        req.setUrl(getTakeUrl() + "user/relieveOpenId");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 上传身份证认证信息
     *
     * @param name   用户名字
     * @param idCard 用户身份证号
     * @param idImg1 身份证图片地址
     * @param idImg2 身份证图片地址
     */
    public void upLoadIdentityInfo(String name, String idCard, String idImg1, String idImg2) {
        UserBean user = AppCache.getUser();
        Map<String, Object> map = createParamsMap();
        map.put("userId", user.getId());
        map.put("phone", user.getPhone());
        map.put("name", name);
        map.put("idCard", idCard);
        map.put("idImg1", idImg1);
        map.put("idImg2", idImg2);
        HttpReq req = new HttpReq(map, MsgID.identity_info);
        req.setUrl(getGuoErServerUrl() + "idCard/submit");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 获取openid accessToken值用于后期操作
     */
    public void getAccess_token(String code) {
        Map<String, Object> map = createParamsMap();
        map.put("type", 3);
        map.put("code", code);
        HttpReq req = new HttpReq(map, MsgID.get_wx_login_token);
        req.setUrl(getGuoErServerUrl() + "getSnsToken");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 获取微信的个人信息
     *
     * @param access_token
     * @param openid
     */
    public void getUserMesg(String access_token, String openid) {
        String path = "https://api.weixin.qq.com/sns/userinfo?access_token=" + access_token + "&openid=" + openid;
        HttpReq req = new HttpReq(createParamsMap(), MsgID.get_wx_login_userinfo);
        req.setUrl(path);
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 代收 提现数据查询
     */
    public void queryTakeMoneyData() {
        UserBean user = AppCache.getUser();
        Map<String, Object> map = createParamsMap();
        map.put("userId", user.getId());
        HttpReq req = new HttpReq(map, MsgID.query_take_money_data);
        req.setUrl(getTakeUrl() + "bankAccount/queryBankAccount");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 代收 申请提现数据提交
     *
     * @param money 要提现的金额
     */
    public void takeMoneyFromBank(String money) {
        UserBean user = AppCache.getUser();
        Map<String, Object> map = createParamsMap();
        map.put("userId", user.getId());
        map.put("stationId", user.getStationId());
        map.put("money", money);
        HttpReq req = new HttpReq(map, MsgID.take_money_data);
        req.setUrl(getTakeUrl() + "bankAccount/requestTransfer");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 代收   查询提现记录
     *
     * @param pageNum
     */
    public void queryTakeMoneyHistoryData(int pageNum) {
        Map<String, Object> map = createParamsMap();
        UserBean user = AppCache.getUser();
        map.put("userId", user.getId());//
        map.put("pageNum", pageNum);
        HttpReq req = new HttpReq(map, MsgID.query_take_money_history_data);
        req.setUrl(getTakeUrl() + "bankAccount/queryTransferRequest");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 代收   获取店内物料下载信息
     */
    //    public void getShopInfoData() {
    //        Map<String, Object> map = createParamsMap();
    //        UserBean user = AppCache.getUser();
    //        map.put("stationId", user.getStationId());//
    //        HttpReq req = new HttpReq(map, MsgID.get_take_shop_info);
    //        req.setUrl(getTakeUrl() + "qrcode/queryList");
    //        HttpLoader.getInstance().sendReq(req);
    //    }

    /**
     * 代收   下载图片
     */
    public void downShopImageData(int type) {
        Map<String, Object> map = createParamsMap();
        UserBean user = AppCache.getUser();
        map.put("type", type);//
        map.put("stationId", user.getStationId());
        HttpReq req = new HttpReq(map, MsgID.get_take_shop_image);
        req.setUrl(getTakeUrl() + "qrcode/download");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 驿站开通提交订单，准备支付
     *
     * @param payType   1 微信  2 支付宝
     * @param quoteCost 开始支付的金额
     * @param realCost  实际支付的金额
     * @param level     1 初级 2 标准 3 专业
     * @param couponsId 推广码
     */
    public void stationOpenOrder(int payType, String quoteCost, String realCost, int level, String couponsId) {
        Map<String, Object> map = createParamsMap();
        map.put("payType", payType);
        map.put("userId", AppCache.getUser().getId());
        map.put("quoteCost", quoteCost);
        map.put("realCost", realCost);
        map.put("level", level);
        map.put("couponsId", couponsId);
        if (payType == 1) {
            map.put("openIdType", -2);
        }
        HttpReq req = new HttpReq(map, MsgID.station_open_order);
        req.setUrl(getTakeUrl() + "stationOpen/submitOrder");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 查询驿站推广码
     *
     * @param promotionCode 推广码
     * @param level         1 初级 2 标准 3 专业
     * @param city          当前所在城市
     */
    public void queryPromotionData(String promotionCode, int level, String city) {
        Map<String, Object> map = createParamsMap();
        map.put("couponsId", promotionCode);
        map.put("level", level);
        map.put("city", city);
        HttpReq req = new HttpReq(map, MsgID.station_query_promotion_code);
        req.setUrl(getTakeUrl() + "payStation/queryPromotionValue");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 购买邮票支付成功的回调 -- 通知服务器修改状态
     *
     * @param orderId payType 微信为1  2 支付宝
     */
    public void stationOpenPayCallBack(String orderId, int payType) {
        Map<String, Object> map = createParamsMap();
        int userId = AppCache.getUser().getId();
        map.put("userId", userId);
        map.put("orderId", orderId);
        map.put("payType", payType);
        map.put("openIdType", -2);
        HttpReq req = new HttpReq(map, MsgID.wxPayCallback);
        req.setUrl(getTakeUrl() + "payStation/appPayReturn");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 驿站申请开通 填写驿站信息
     *
     * @param name      驿站名称
     * @param admin     驿站负责人
     * @param phone     驿站电话
     * @param province  站省
     * @param city      市
     * @param region    区
     * @param address   详细地址
     * @param latitude
     * @param longitude
     */
    public void submitStationInfoData(String name, String admin, String phone, String province, String city, String region, String address, String latitude, String longitude) {
        Map<String, Object> map = createParamsMap();
        UserBean userBean = AppCache.getUser();
        map.put("userId", userBean.getId());
        map.put("name", name);
        map.put("admin", admin);
        map.put("phone", phone);
        map.put("province", province);
        map.put("city", city);
        map.put("region", region);
        map.put("address", address);
        map.put("latitude", latitude);
        map.put("longitude", longitude);
        HttpReq req = new HttpReq(map, MsgID.station_open_info_submit);
        req.setUrl(getTakeUrl() + "stationOpen/submitStationVerify");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 我的驿站信息
     */
    public void stationDetailData() {
        Map<String, Object> map = createParamsMap();
        int userId = AppCache.getUser().getId();
        map.put("userId", userId);
        HttpReq req = new HttpReq(map, MsgID.query_station_info);
        req.setUrl(getTakeUrl() + "stationOpen/queryDetails");
        HttpLoader.getInstance().sendReq(req);

    }

    /**
     * 查询活动数据
     *
     * @param activeType 0 进行中  1历史记录
     */
    public void queryActiveData(int activeType) {
        Map<String, Object> map = createParamsMap();
        int stationId = AppCache.getUser().getStationId();
        map.put("stationId", stationId);
        int msgID = 0;
        String url = "";
        if (activeType == 0) {
            msgID = MsgID.query_activing_data;
            url = "ranking/queryRankingCurrent";
        } else {
            msgID = MsgID.query_active_history_data;
            url = "ranking/queryRankingHistory";
        }
        HttpReq req = new HttpReq(map, msgID);
        req.setUrl(getTakeUrl() + url);
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 查询活动数据
     * 当前榜单详情 week 传空  历史才有
     *
     * @param type 1 代收  2 寄件
     * @param week 活动期次 201738
     */
    public void queryActiveRankData(int type, int week, int activeType) {
        Map<String, Object> map = createParamsMap();
        int stationId = AppCache.getUser().getStationId();
        map.put("stationId", stationId);
        map.put("type", type);
        if (activeType == 1) {
            map.put("week", week);
        } else {
            map.put("week", "");
        }
        HttpReq req = new HttpReq(map, MsgID.query_active_rank_list_data);
        req.setUrl(getTakeUrl() + "ranking/queryRankingDetails");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 查询app活动配置
     */
    public void queryActiveConfig() {
        Map<String, Object> map = createParamsMap();
        int stationId = AppCache.getUser().getStationId();
        map.put("stationId", stationId);
        HttpReq req = new HttpReq(map, MsgID.query_active_config_data);
        req.setUrl(getTakeUrl() + "index/queryConfig");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 查询邀请开通驿站记录
     */
    public void queryStationInviteOpenRecord() {
        Map<String, Object> map = createParamsMap();
        map.put("userId", AppCache.getUser().getId());
        HttpReq req = new HttpReq(map, MsgID.query_station_invite_open);
        req.setUrl(getTakeUrl() + "stationRecommend/queryReward");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 更改驿站头像
     */
    public void updateStorePhoto(Object photoUrl) {
        Map<String, Object> map = createParamsMap();
        map.put("stationId", AppCache.getUser().getStationId());
        map.put("headImage", photoUrl);
        HttpReq req = new HttpReq(map, MsgID.take_update_store_photo);
        req.setUrl(getTakeUrl() + "station/uploadHeadImage");
        HttpLoader.getInstance().sendReq(req);
    }
    //**********************************************火箭侠同城新版本********************************************************************//

    /**
     * 获取火箭侠首页数据
     */
    public void getCourierHomeData(double latitude, double longitude) {
        Map<String, Object> map = createParamsMap();
        map.put("userId", AppCache.getUser().getId());//
        map.put("latitude", latitude);
        map.put("longitude", longitude);
        HttpReq req = new HttpReq(map, MsgID.get_courier_home_data);
        req.setUrl(getTakeUrl() + "courier/index");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 轮询上传火箭侠的位置
     *
     * @param latitude
     * @param longitude
     */
    public void uploadCourierLocation(double latitude, double longitude) {
        Map<String, Object> map = createParamsMap();
        map.put("userId", AppCache.getUser().getId());
        map.put("latitude", latitude);
        map.put("longitude", longitude);
        HttpReq req = new HttpReq(map, MsgID.courier_location_refresh);
        req.setUrl(getTakeUrl() + "courier/refresh");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 火箭侠开工或收工
     *
     * @param startWork
     */
    public void courierStartOrCloseWork(boolean startWork) {
        Map<String, Object> map = createParamsMap();
        map.put("userId", AppCache.getUser().getId());
        map.put("startWork", startWork);
        HttpReq req = new HttpReq(map, MsgID.courier_start_or_close_work);
        req.setUrl(getTakeUrl() + "courier/startWork");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 火箭侠是否接单
     *
     * @param receiverOrder
     */
    public void courierIsReceiverOrderork(boolean receiverOrder) {
        Map<String, Object> map = createParamsMap();
        map.put("userId", AppCache.getUser().getId());
        map.put("receiverOrder", receiverOrder);
        HttpReq req = new HttpReq(map, MsgID.courier_receiver_order);
        req.setUrl(getTakeUrl() + "courier/receiverOrder");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 火箭侠任务阶段
     */
    public void getTaskStageDetail(int taskId) {
        Map<String, Object> map = createParamsMap();
        map.put("userId", AppCache.getUser().getId());
        map.put("taskId", taskId);
        HttpReq req = new HttpReq(map, MsgID.courier_task_step_detail);
        req.setUrl(getTakeUrl() + "courier/taskStep");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 火箭侠完成寄件人联系步骤
     *
     * @param taskId
     */
    public void updateTaskStepContractData(int taskId) {
        Map<String, Object> map = createParamsMap();
        map.put("userId", AppCache.getUser().getId());
        map.put("taskId", taskId);
        HttpReq req = new HttpReq(map, MsgID.courier_task_step_update);
        req.setUrl(getTakeUrl() + "courier/completeContact");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 火箭侠完成收件人联系步骤
     *
     * @param taskId
     */
    public void finishReceiverContractData(int taskId) {
        Map<String, Object> map = createParamsMap();
        map.put("userId", AppCache.getUser().getId());
        map.put("taskId", taskId);
        HttpReq req = new HttpReq(map, MsgID.courier_task_step_receiver_contract);
        req.setUrl(getTakeUrl() + "courier/completeGiveContact");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 火箭侠获取任务详情界面列表和数据
     *
     * @param taskId
     */
    public void getCourierTaskDetailData(int taskId) {
        Map<String, Object> map = createParamsMap();
        map.put("userId", AppCache.getUser().getId());
        map.put("taskId", taskId);
        HttpReq req = new HttpReq(map, MsgID.courier_get_task_detail_data);
        req.setUrl(getTakeUrl() + "courier/taskDetail");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 扫描用户二维码验证接口
     */
    public void scanUserQrCodeData(String value, Object taskId) {
        Map<String, Object> map = createParamsMap();
        map.put("value", value);
        map.put("taskId", taskId);
        HttpReq req = new HttpReq(map, MsgID.courier_scan_user_qrcode_data);
        req.setUrl(getTakeUrl() + "courier/scannParcel");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 火箭侠验证寄件码接口
     */
    public void confirmSendCodeData(String checkCode, Object taskId) {
        Map<String, Object> map = createParamsMap();
        map.put("checkCode", checkCode);
        map.put("taskId", taskId);
        HttpReq req = new HttpReq(map, MsgID.courier_check_code_data);
        req.setUrl(getTakeUrl() + "courier/checkByCheckCode");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 火箭侠验证收件码接口
     *
     * @param checkCode
     * @param taskId
     */
    public void confirmReceiverCodeData(String checkCode, Object taskId) {
        Map<String, Object> map = createParamsMap();
        map.put("checkCode", checkCode);
        map.put("taskId", taskId);
        HttpReq req = new HttpReq(map, MsgID.courier_check_receiver_code_data);
        req.setUrl(getTakeUrl() + "courier/completeCity");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 火箭侠快递柜揽收接口
     */
    public void courierCabinetTakeParcelData(Object taskId, double lat, double lng) {
        Map<String, Object> map = createParamsMap();
        map.put("taskId", taskId);
        map.put("userId", AppCache.getUser().getId());
        map.put("latitude", lat);
        map.put("longitude", lng);
        HttpReq req = new HttpReq(map, MsgID.courier_cabinet_take_parcel_data);
        req.setUrl(getTakeUrl() + "courier/checkExpress");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 火箭侠包裹列表新增更新（删除或新增）图片接口
     *
     * @param detailId
     * @param type           1删除,2新增
     * @param parentPosition 对于删除图片操作，parentPosition 是当前要刷新的item
     */
    public void courierParcelImageData(String detailId, int type, String imagePath, int parentPosition) {
        Map<String, Object> map = createParamsMap();
        map.put("detailId", detailId);
        map.put("type", type);
        map.put("imagePath", imagePath);
        int msgId = 0;
        if (type == 2) {
            msgId = MsgID.courier_parcel_process_image_data;
        } else {
            msgId = MsgID.courier_parcel_process_image_data + 1;
        }
        HttpReq req = new HttpReq(map, msgId);
        req.setArg1(parentPosition);
        req.setUrl(getTakeUrl() + "courier/processDetailImage");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 火箭侠完成包裹列表揽收
     *
     * @param taskId
     */
    public void courierFinishParcelTakeData(Object taskId) {
        Map<String, Object> map = createParamsMap();
        map.put("taskId", taskId);
        map.put("userId", AppCache.getUser().getId());
        HttpReq req = new HttpReq(map, MsgID.courier_parcel_list_take_data);
        req.setUrl(getTakeUrl() + "courier/completeAcceptance");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 获取火箭侠的二位码
     */
    public void getCourierQRCode() {
        Map<String, Object> map = createParamsMap();
        map.put("id", AppCache.getUser().getId());
        HttpReq req = new HttpReq(map, MsgID.courier_get_qrcode);
        req.setUrl(getTakeUrl() + "getQrCode");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 火箭侠任务异常
     */
    public void courierTaskException(Object taskId, Object exceptionId, String remark) {
        Map<String, Object> map = createParamsMap();
        map.put("taskId", taskId);
        map.put("exceptionId", exceptionId);
        map.put("remark", remark);
        HttpReq req = new HttpReq(map, MsgID.courier_task_exception);
        req.setUrl(getTakeUrl() + "courier/exceptionTask");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 火箭侠拒收包裹
     *
     * @param detailId
     * @param exceptionId
     * @param remark
     */
    public void courierRejectionParcel(Object detailId, Object exceptionId, String remark) {
        Map<String, Object> map = createParamsMap();
        map.put("detailId", detailId);
        map.put("exceptionId", exceptionId);
        map.put("remark", remark);
        HttpReq req = new HttpReq(map, MsgID.courier_rejection_parcel);
        req.setUrl(getTakeUrl() + "courier/rejectionParcel");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 火箭侠揽收完成后查询是否有下一个任务需要揽收的
     */
    public void courierQueryNextParcels() {
        Map<String, Object> map = createParamsMap();
        map.put("userId", AppCache.getUser().getId());
        HttpReq req = new HttpReq(map, MsgID.courier_query_next_parcel);
        req.setUrl(getTakeUrl() + "courier/nextTask");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 进行袋子和包裹绑定
     *
     * @param bagCode  袋子编号
     * @param parcelId 包裹ID
     */
    public void bagCodeBindParcel1(String bagCode, String parcelId, int position) {
        Map<String, Object> map = createParamsMap();
        map.put("bagCode", bagCode);
        map.put("parcelId", parcelId);
        HttpReq req = new HttpReq(map, MsgID.courier_bagcode_bindparcel);
        req.setArg1(position);
        req.setUrl(getTakeUrl() + "station/bindBag");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * @param parcelId
     * @param position
     */
    public void reGetOpenBoxCode(String parcelId, int position) {
        Map<String, Object> map = createParamsMap();
        map.put("parcelId", parcelId);
        HttpReq req = new HttpReq(map, MsgID.courier_reget_open_box_code);
        req.setArg1(position);
        req.setUrl(getTakeUrl() + "courier/gege/boxOrderAgain");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * @param taskId
     */
    public void sameCityParcelComplete(Object taskId) {
        Map<String, Object> map = createParamsMap();
        map.put("taskId", taskId);
        HttpReq req = new HttpReq(map, MsgID.courier_samecity_task_complete);
        req.setUrl(getTakeUrl() + "courier/completeCityAcceptance");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 重新获取收件码
     *
     * @param taskId
     */
    public void sameCityGetReceiveCode(Object taskId) {
        Map<String, Object> map = createParamsMap();
        map.put("taskId", taskId);
        HttpReq req = new HttpReq(map, MsgID.courier_samecity_getreceive_code);
        req.setUrl(getTakeUrl() + "courier/sendCityReceive");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 获取火箭侠个人中心数据
     */
    public void getCourierCenterData() {
        Map<String, Object> map = createParamsMap();
        map.put("id", AppCache.getUser().getId());
        HttpReq req = new HttpReq(map, MsgID.courier_get_center_data);
        req.setUrl(getTakeUrl() + "userInfo");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 代收  绑定微信账号
     */
    public void bindCourierWXAccout(String openId, String wxAccountName, String wxHeadImgUrl) {
        Map<String, Object> map = createParamsMap();
        UserBean user = AppCache.getUser();
        map.put("userId", user.getId());//
        map.put("openId", openId);
        map.put("wxAccountName", wxAccountName);
        map.put("wxHeadImgUrl", wxHeadImgUrl);
        HttpReq req = new HttpReq(map, MsgID.courier_bind_wx_accout);
        req.setUrl(getTakeUrl() + "courier/bindWeixin");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 火箭侠  解除微信绑定
     */
    public void deleteCourierWXAccout() {
        Map<String, Object> map = createParamsMap();
        UserBean user = AppCache.getUser();
        map.put("userId", user.getId());//
        HttpReq req = new HttpReq(map, MsgID.courier_delete_wx_accout);
        req.setUrl(getTakeUrl() + "courier/unBindWeixin");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 个人中心   历史任务列表
     */
    public void walletHistoryTask(int pageNo) {
        Map<String, Object> map = createParamsMap();
        UserBean user = AppCache.getUser();
        map.put("userId", user.getId());
        map.put("pageNo", pageNo);
        HttpReq req = new HttpReq(map, MsgID.wallet_history_task);
        req.setUrl(getTakeUrl() + "courier/tasks");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 火箭侠个人中心  获取历史任务的详情
     *
     * @param taskId
     */
    public void getHistoryTaskDetail(Object taskId) {
        Map<String, Object> map = createParamsMap();
        UserBean user = AppCache.getUser();
        map.put("userId", user.getId());
        map.put("taskId", taskId);
        HttpReq req = new HttpReq(map, MsgID.get_history_task_detail);
        req.setUrl(getTakeUrl() + "courier/taskDetail");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 个人中心   资金记录列表
     */
    public void walletMoneyRecord(int pageNo, int type) {
        Map<String, Object> map = createParamsMap();
        UserBean user = AppCache.getUser();
        map.put("userId", user.getId());
        map.put("pageNo", pageNo);
        map.put("type", type);
        HttpReq req = new HttpReq(map, MsgID.wallet_money_record);
        req.setUrl(getTakeUrl() + "user/accountBalance");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 火箭侠个人中心提现记录
     *
     * @param pageNo
     */
    public void courierWalletTakeMoneyRecord(int pageNo) {
        Map<String, Object> map = createParamsMap();
        UserBean user = AppCache.getUser();
        map.put("userId", user.getId());
        map.put("pageNo", pageNo);
        HttpReq req = new HttpReq(map, MsgID.courier_wallet_take_money_record);
        req.setUrl(getTakeUrl() + "courier/getWithdrawalsRecords");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 火箭侠查询提现信息
     */
    public void queryCourierWalletTakeMoneyInfo() {
        Map<String, Object> map = createParamsMap();
        UserBean user = AppCache.getUser();
        map.put("userId", user.getId());
        HttpReq req = new HttpReq(map, MsgID.query_courier_wallet_take_money_info);
        req.setUrl(getTakeUrl() + "courier/getWithdrawals");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 火箭侠账户提现
     */
    public void courierWalletTakeMoneyFromAccount(Object money) {
        Map<String, Object> map = createParamsMap();
        UserBean user = AppCache.getUser();
        map.put("userId", user.getId());
        map.put("money", money);
        HttpReq req = new HttpReq(map, MsgID.courier_wallet_take_money_from_account);
        req.setUrl(getTakeUrl() + "courier/withdrawals");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 火箭侠卫星仓扫码火箭侠二维码
     */
    public void taskSatelliteWarehouseQRCode(Object courierId) {
        Map<String, Object> map = createParamsMap();
        map.put("courierId", courierId);
        HttpReq req = new HttpReq(map, MsgID.task_satellite_warehouse_qr_code);
        req.setUrl(getTakeUrl() + "wareHouse/scannCourier");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 火箭侠交接详情交接入仓
     */
    public void parcelHandoverWarehous(ArrayList<NewParcelBean> items, Object taskId) {
        String info = getParcelDatas(items);
        Map<String, Object> map = createParamsMap();
        map.put("taskId", taskId);
        map.put("courierId", AppCache.getUser().getId());
        map.put("parcelDatas", info);
        HttpReq req = new HttpReq(map, MsgID.parcel_handover_in_transfer);
        req.setUrl(getTakeUrl() + "wareHouse/updateTaskStatus");
        HttpLoader.getInstance().sendReq(req);
    }

    private String getParcelDatas(ArrayList<NewParcelBean> items) {
        StringBuilder sb = new StringBuilder();
        sb.append("[");
        // [{"detailId":xxx,"backType":xxx,"backRemark":xxx}]
        for (Iterator<NewParcelBean> it = items.iterator(); it.hasNext(); ) {
            NewParcelBean item = it.next();
            sb.append("{");
            sb.append("'detailId':'").append(item.getDetailId()).append("',");
            sb.append("'backType':'").append(item.getParcelStatus()).append("',");
            sb.append("'backRemark':'").append(item.getBackRemark()).append("',");
            sb.append("}");
            if (it.hasNext()) {
                sb.append(",");
            }
        }
        sb.append("]");
        String parcels = sb.toString().replace("'", "\"");
        return parcels;
    }

    /**
     * 卫星仓管理界面
     */
    public void courierSatelliteWareInfo() {
        Map<String, Object> map = createParamsMap();
        UserBean user = AppCache.getUser();
        map.put("courierId", user.getId());
        HttpReq req = new HttpReq(map, MsgID.courier_satellite_warehouse_info);
        req.setUrl(getTakeUrl() + "wareHouse/getWareHouse");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 卫星仓管理界面
     */
    public void courierSatelliteWareUpdateTime(Object id, String startTime, String endTime) {
        Map<String, Object> map = createParamsMap();
        map.put("id", id);
        map.put("transStart", startTime);
        map.put("transEnd", endTime);
        HttpReq req = new HttpReq(map, MsgID.courier_satellite_warehouse_update_time);
        req.setUrl(getTakeUrl() + "wareHouse/updateHandoverTime");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 火箭侠仓管理交接记录
     */
    public void courierTodayTransferRecords() {
        Map<String, Object> map = createParamsMap();
        UserBean user = AppCache.getUser();
        map.put("tranCourierId", user.getId());
        HttpReq req = new HttpReq(map, MsgID.courier_today_tansfer_records);
        req.setUrl(getTakeUrl() + "wareHouse/transRecords");
        HttpLoader.getInstance().sendReq(req);
    }


    /**
     * 火箭侠交接地点列表
     */
    public void courierTransferList(double latitude, double longitude) {
        Map<String, Object> map = createParamsMap();
        map.put("courierId", AppCache.getUser().getId());
        map.put("latitude", latitude);
        map.put("longitude", longitude);
        HttpReq req = new HttpReq(map, MsgID.courier_tansfer_list);
        req.setUrl(getTakeUrl() + "wareHouse/searchWareHouse");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 设置默认仓库
     *
     * @param wareHouseId
     */
    public void courierSetDefaultTransfer(Object wareHouseId) {
        Map<String, Object> map = createParamsMap();
        map.put("courierId", AppCache.getUser().getId());
        map.put("wareHouseId", wareHouseId);
        HttpReq req = new HttpReq(map, MsgID.courier_set_default_tansfer);
        req.setUrl(getTakeUrl() + "wareHouse/setDefaultWareHouse");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 火箭联盟-----有偿代收包裹设置信息
     */
    public void getTakePaid() {
        UserBean user = AppCache.getUser();
        Map<String, Object> map = createParamsMap();
        map.put("stationId", user.getStationId());
        HttpReq req = new HttpReq(map, MsgID.get_take_paid);
        req.setUrl(getTakeUrl() + "user/getStationCharge");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 火箭联盟--------提交设置费用的信息
     *
     * @param chargeType
     * @param chargeObject
     * @param payType
     * @param smallParcel
     * @param timeoutSmallParcel
     * @param timeoutBigParcel
     */
    public void submitTakePaidInfo(Object chargeType, Object chargeObject, Object payType, Object smallParcel, Object bigParcel, Object timeoutSmallParcel, Object timeoutBigParcel) {
        UserBean user = AppCache.getUser();
        long timeOut = 72 * 60;
        Map<String, Object> map = createParamsMap();
        map.put("stationId", user.getStationId());
        map.put("userId", user.getId());
        map.put("chargeType", chargeType);
        map.put("chargeObject", chargeObject);
        map.put("payType", payType);
        map.put("smallParcel", smallParcel);
        map.put("bigParcel", bigParcel);
        map.put("timeout", timeOut);
        map.put("timeoutSmallParcel", timeoutSmallParcel);
        map.put("timeoutBigParcel", timeoutBigParcel);
        HttpReq req = new HttpReq(map, MsgID.submit_take_paid_info);
        req.setUrl(getTakeUrl() + "user/setStationCharge");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 火箭联盟-----切换至火箭侠
     */
    public void switchCourier() {
        UserBean user = AppCache.getUser();
        Map<String, Object> map = createParamsMap();
        map.put("phone", user.getPhone());
        map.put("type", 1);
        HttpReq req = new HttpReq(map, MsgID.switch_courier);
        req.setUrl(getTakeUrl() + "user/changeLogin");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 火箭侠-----切换至火箭联盟
     */
    public void switchTake() {
        UserBean user = AppCache.getUser();
        Map<String, Object> map = createParamsMap();
        map.put("phone", user.getPhone());
        map.put("type", 2);
        HttpReq req = new HttpReq(map, MsgID.switch_take);
        req.setUrl(getTakeUrl() + "user/changeLogin");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 火箭侠-----切换至火箭联盟弹框申请开通
     */
    public void openTheStation() {
        UserBean user = AppCache.getUser();
        Map<String, Object> map = createParamsMap();
        map.put("phone", user.getPhone());
        HttpReq req = new HttpReq(map, MsgID.open_the_station);
        req.setUrl(getTakeUrl() + "user/openRocketUnion");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 火箭侠登录、确认验证码
     *
     * @param phone
     */
    public void courierLoginVerifyCode(String phone, String code, int type) {
        Map<String, Object> map = createParamsMap();
        map.put("phone", phone);
        map.put("code", code);
        HttpReq req = new HttpReq(map, MsgID.courier_login_verify_code + type);
        req.setUrl(getTakeUrl() + "codeLogin");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 火箭侠获取短信验证码
     *
     * @param phone
     */
    public void courierGetSMSVerifyCode(String phone, String codeType) {
        Map<String, Object> map = createParamsMap();
        map.put("phone", phone);
        if (!StringUtils.isEmpty(codeType)) {
            map.put("smsType", codeType);
        }
        map.put("timestamp", System.currentTimeMillis());
        JSONObject jsonObject = new JSONObject(map);
        String data = DesUtil.ebotongEncrypto(jsonObject.toString());
        map.put("sendInfo", data);
        HttpReq req = new HttpReq(map, MsgID.courier_send_verifyNum);
//        req.setUrl(getTakeUrl() + "sendCode");
        req.setUrl(getTakeUrl() + "sendCodeDes");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 火箭侠预约培训地址
     */
    public void courierBusinessTrainingAddress(String province, String city, String distrct) {
        Map<String, Object> map = createParamsMap();
        map.put("province", province);
        map.put("city", city);
        map.put("district", distrct);
        HttpReq req = new HttpReq(map, MsgID.courier_business_training_address);
        req.setUrl(getTakeUrl() + "getTrains");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 火箭侠预约培训
     */
    public void courierBusinessTraining(String wareHouseName, String trainAddress, double longitude, double latitude) {
        Map<String, Object> map = createParamsMap();
        map.put("userId", AppCache.getUser().getId());
        map.put("trainAddress", trainAddress);
        map.put("longitude", longitude);
        map.put("latitude", latitude);
        map.put("wareHouseName", wareHouseName);
        HttpReq req = new HttpReq(map, MsgID.courier_business_training);
        req.setUrl(getTakeUrl() + "courier/bespeakTrain");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 火箭侠提交身份证相关信息
     */
    public void courierSubmitIdCardInfo(IDCardInfoBean idCardInfoBean) {

        Map<String, Object> map = createParamsMap();
        map.put("userId", AppCache.getUser().getId());
        map.put("idCardFaceImg", idCardInfoBean.getiDCardImagePath());
        map.put("idCardBackImg", idCardInfoBean.getInHandCardImagePath());
        map.put("name", idCardInfoBean.getName());
        map.put("sex", idCardInfoBean.getGender());
        map.put("nation", idCardInfoBean.getEthnic());
        map.put("idCardNo", idCardInfoBean.getIdNumber());
        map.put("addresss", idCardInfoBean.getAddress());
        HttpReq req = new HttpReq(map, MsgID.courier_submit_idcard_info);
        req.setUrl(getTakeUrl() + "courier/submitCard");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 申请火箭侠物料获取
     */
    public void getCourierMaterial() {
        Map<String, Object> map = createParamsMap();
        HttpReq req = new HttpReq(map, MsgID.get_courier_material);
        req.setUrl(getTakeUrl() + "getReceives");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * @param payType 1 微信  2 支付宝
     */
    public void courierRegisterMateralPay(int payType) {
        Map<String, Object> map = createParamsMap();
        map.put("payType", payType);
        map.put("userId", AppCache.getUser().getId());
        int msgId = 0;
        if (payType == 1) {
            map.put("openIdType", -2);
            msgId = MsgID.courier_weixinPay;
        } else {
            msgId = MsgID.courier_aliPay;
        }
        HttpReq req = new HttpReq(map, msgId);
        req.setUrl(getTakeUrl() + "courier/submitOrder");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 支付成功的回调 -- 通知服务器修改状态
     *
     * @param orderId payType 微信为1  2 支付宝
     */
    public void courierPayCallBack(String orderId, int payType) {
        Map<String, Object> map = createParamsMap();
        int userId = AppCache.getUser().getId();
        map.put("userId", userId);
        map.put("orderId", orderId);
        map.put("payType", payType);
        map.put("openIdType", -2);
        HttpReq req = new HttpReq(map, MsgID.wxPayCallback);
        req.setUrl(getTakeUrl() + "courier/appPayReturn");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 火箭侠包裹列表中用户实名认证信息提交
     */
    public void courierParcelListUserIdCardSubmit(String userPhone, String name, String idCard, String idImg1, String idImg2) {
        Map<String, Object> map = createParamsMap();
        int userId = AppCache.getUser().getId();
        map.put("courierId", userId);
        map.put("idCardUserPhone", userPhone);
        map.put("name", name);
        map.put("idCard", idCard);
        map.put("idImg1", idImg1);
        map.put("idImg2", idImg2);
        map.put("fromType", 5);
        HttpReq req = new HttpReq(map, MsgID.courier_parcel_list_userIdCard_submit);
        req.setUrl(getTakeUrl() + "idCard/submit");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 更新推送的token
     *
     * @param token
     */
    public void updatePushToken(String token) {
        Map<String, Object> map = createParamsMap();
        int userId = AppCache.getUser().getId();
        map.put("userId", userId);
        map.put("pushToken", token);
        HttpReq req = new HttpReq(map, MsgID.push_token);
        req.setUrl(getTakeUrl() + "courier/loginPush");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 火箭侠战队首页战队状态接口
     */
    public void teamCenterHoneData() {
        Map<String, Object> map = createParamsMap();
        int userId = AppCache.getUser().getId();
        map.put("userId", userId);
        HttpReq req = new HttpReq(map, MsgID.courier_team_center_home_data);
        req.setUrl(getTakeUrl() + "team/index");
        HttpLoader.getInstance().sendReq(req);
    }
    /**
     * 获取战队首页banner
     */
    public void getTeamHomeBannerData(){
        Map<String, Object> map = createParamsMap();
        int userId = AppCache.getUser().getId();
        map.put("userId", userId);
        map.put("appType", 64);
        map.put("city", "");
        HttpReq req = new HttpReq(map, MsgID.courier_team_home_banner);
        req.setUrl(getTakeUrl() + "team/banner");
        HttpLoader.getInstance().sendReq(req);
    }
    /**
     * 火箭创建战队
     *
     * @param teamName      战队名称
     * @param teamSlogan    宣言
     * @param teamIntroduce 介绍
     */
    public void teamCreate(String teamName, String teamSlogan, String teamIntroduce) {
        Map<String, Object> map = createParamsMap();
        int userId = AppCache.getUser().getId();
        map.put("userId", userId);
        map.put("teamName", teamName);
        map.put("teamSlogan", teamSlogan);
        map.put("teamIntroduce", teamIntroduce);
        HttpReq req = new HttpReq(map, MsgID.courier_team_create);
        req.setUrl(getTakeUrl() + "team/createTeam");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 战队详情
     *
     * @param teamId
     */
    public void getTeamDetail(Object teamId) {
        Map<String, Object> map = createParamsMap();
        int userId = AppCache.getUser().getId();
        map.put("userId", userId);
        map.put("teamId", teamId);
        HttpReq req = new HttpReq(map, MsgID.courier_team_detail);
        req.setUrl(getTakeUrl() + "team/teamDetail");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 战队详情列表
     *
     * @param teamId
     */
    public void getTeamDetailList(Object teamId, int sortType) {
        Map<String, Object> map = createParamsMap();
        int userId = AppCache.getUser().getId();
        map.put("userId", userId);
        map.put("teamId", teamId);
        map.put("sortType", sortType);
        HttpReq req = new HttpReq(map, MsgID.courier_team_detail_list);
        req.setArg1(sortType);
        req.setUrl(getTakeUrl() + "team/courierDetailList");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 战队申请列表
     */
    public void teamApplyList(Object teamId) {
        Map<String, Object> map = createParamsMap();
        int userId = AppCache.getUser().getId();
        map.put("userId", userId);
        map.put("teamId", teamId);
        HttpReq req = new HttpReq(map, MsgID.courier_team_apply_list);
        req.setUrl(getTakeUrl() + "team/checkList");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 战队解散或退出
     *
     * @param operType 1 退出  2  解散
     */
    public void courierTeamCancel(Object teamId, int operType) {
        Map<String, Object> map = createParamsMap();
        int userId = AppCache.getUser().getId();
        map.put("userId", userId);
        map.put("teamId", teamId);
        map.put("operType", operType);
        HttpReq req = new HttpReq(map, MsgID.courier_team_cancel);
        req.setUrl(getTakeUrl() + "team/cancel");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 获取战区战队列表
     *
     * @param type 0 运营中  1 组队中
     */
    public void getZoneTeamList(int position, int type) {
        Map<String, Object> map = createParamsMap();
        int userId = AppCache.getUser().getId();
        map.put("userId", userId);
        if (type == 0) {
            map.put("teamFlag", 2);
        } else {
            map.put("teamFlag", 1);
        }
        map.put("sort", position);
        HttpReq req = new HttpReq(map, MsgID.courier_team_zone_list + type);
        req.setArg1(position);
        req.setUrl(getTakeUrl() + "team/storeTeamList");
        HttpLoader.getInstance().sendReq(req);
    }
    /**
     * 申请人详情中的拒绝或者同意操作
     */
    public void teamMemberCheck(Object teamId,int id,int status) {
        Map<String, Object> map = createParamsMap();
        int userId = AppCache.getUser().getId();
        map.put("userId", userId);
        map.put("teamId", teamId);
        map.put("id", id);
        map.put("status", status);
        HttpReq req = new HttpReq(map, MsgID.team_member_check);
        req.setArg1(status);
        req.setUrl(getTakeUrl() + "team/check");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 申请加入战队
     */
    public void applyToTeam(Object teamId, String introduce) {
        Map<String, Object> map = createParamsMap();
        int userId = AppCache.getUser().getId();
        map.put("userId", userId);
        map.put("teamId", teamId);
        map.put("introduce", introduce);
        HttpReq req = new HttpReq(map, MsgID.courier_team_apply_team);
        req.setUrl(getTakeUrl() + "team/apply");
        HttpLoader.getInstance().sendReq(req);
    }
    /**
     * 战队过往成就
     */
    public void courierTeamAchievement(Object teamId) {
        Map<String, Object> map = createParamsMap();
        int userId = AppCache.getUser().getId();
        map.put("userId", userId);
        map.put("teamId", teamId);
        HttpReq req = new HttpReq(map, MsgID.courier_team_pass_achievement_list);
        req.setUrl(getTakeUrl() + "team/hisTeamList");
        HttpLoader.getInstance().sendReq(req);
    }

    /**
     * 获取所有战队列表
     * @param monthType //1：总收入，2：平均分，3,总里程，4，总单量
     * @param type 1 本省  2 全国
     */
    public void getAllTeamList(int monthType, int type) {
        Map<String, Object> map = createParamsMap();
        int userId = AppCache.getUser().getId();
        map.put("userId", userId);
        map.put("operFlag", type+1);
        map.put("sort", monthType);
        HttpReq req = new HttpReq(map, MsgID.courier_team_all_list + type);
        req.setArg1(monthType);
        req.setUrl(getTakeUrl() + "team/countryTeamList");
        HttpLoader.getInstance().sendReq(req);
    }

}

